package com.bruce.codeFactory.designMode;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPath;
import com.google.gson.*;
import com.google.gson.reflect.TypeToken;
import com.jayway.jsonpath.JsonPath;

import java.util.LinkedHashMap;
import java.util.Map.Entry;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonPrimitive;
import com.jayway.jsonpath.spi.json.JsonOrgJsonProvider;

import javax.xml.xpath.XPath;
import java.util.Map;

/**
 * @author luotuan
 * @Description
 * @create 2019-02-21 22:00
 **/
public class Test {
    public static void main(String[] args) {
        String json = "{\n" +
                "    \"infCrmRequest\": {\n" +
                "        \"id\": \"165300436\", \n" +
                "        \"orderCode\": \"67134370011\", \n" +
                "        \"custOrderCode\": \"21582149036\", \n" +
                "        \"requestGroupCode\": \"21582149036\", \n" +
                "        \"requestType\": \"10N\", \n" +
                "        \"orderCount\": 1, \n" +
                "        \"state\": 1, \n" +
                "        \"stateDate\": \"2019-02-27 00:00:00\", \n" +
                "        \"createDate\": \"2019-02-27 00:00:00\"\n" +
                "    }\n" +
                "}";
//        Gson gson = new Gson();
//        JsonParser parser = new JsonParser();
//        JsonObject object = parser.parse(json).getAsJsonObject();
//        String jsonPath = "$.infCrmRequest.id";
//        String[] array = jsonPath.split("\\.");
//        String ss = JsonPath.read(json, jsonPath);
//        String replaceStr = "\"id\""+": "+"\"165300436\"";
//        System.out.println(replaceStr);
//        json.replace(replaceStr,"");
//        System.out.println(json);
        //System.out.println(ss);
        JSONObject object = JSONObject.parseObject(json);
        JSONPath.set(object,"$.infCrmRequest.id",null);
        System.out.println(object.toJSONString());
    }
}
